package com.redis.controller;

import com.redis.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.Date;

/**
 * 请求访问视图模板接口
 * @author YI
 * @date 2018-3-15 15:51:40
 */
@Controller
@RequestMapping("/api")
public class FreemarkerController {

    /**
     * 返回视图和数据
     * @return
     */
    @RequestMapping("/freemarker")
    public ModelAndView freemarkerNotName(){
        ModelAndView modelAndView = new ModelAndView();

        User user = new User("12345", "张三", 99.9);
        modelAndView.addObject("user", user);

        // /index的路径为resources\templates\index.ftl
        modelAndView.setViewName("/index");
        return modelAndView;
    }
}
